
<template>
  <div id="mainMenu" class="p-box">
    <div class="p-return">
      <mu-appbar color="primary" class="lan-header">
        <mu-button icon slot="left" v-close>
          <i class="iconfont angle-left iconangle-left"></i>
          <span class="lan-header-back">返回</span>
        </mu-button>公用账号
      </mu-appbar>
    </div>
    <div class="p-content">
      <div class="m-box" v-for="(menu) in accountList" :key="menu.id">
        <div class="m-title">{{menu.moduleName}}</div>
        <div class="m-content account">
          <div class="menu-list">
            <label>公用账号：</label>
            <span>{{menu.accountName}}</span>
          </div>
          <div class="menu-list">
            <label>公用密码：</label>
            <span>{{menu.accountValue}}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "mainMenu",
  components: {},
  data() {
    return {
      accountList: [
        {
          id: "1",
          moduleName: "现行规范库",
          accountName: "",
          accountValue: ""
        },
        {
          id: "2",
          moduleName: "工艺做法库",
          accountName: "",
          accountValue: ""
        }
      ]
    };
  },
  computed: {},
  created() {
    this.getCount(1);
    this.getCount(2);
  },
  mounted() {},
  watch: {},
  methods: {
    skipPage(item) {
      if (item.path.startsWith("http") || item.path.startsWith("https")) {
        let a = document.createElement("a");
        a.href = item.path;
        a.target = "_blank";
        a.click();
      } else {
        this.$router.push({
          name: item.path
        });
      }
    },
    getCount(type) {
      this.$openLoading();
      let dicCode = "";
      if (type == 1) {
        //现行
        dicCode = "CURRENT_SPEC_LIBRARY";
      } else {
        //工艺
        dicCode = "PROCESS_LIBRARY";
      }
      let params = {
        obj: { dicCode: dicCode },
        pageNo: 1,
        pageSize: 0
      };
      this.$A.Go("post", "/safety/dict/selectDictDesc", params).then(res => {
        this.$closeLoading();
        let data = res.body.rows[0];
        if (type == 1) {
          this.accountList[0].accountName = data.commonName;
          this.accountList[0].accountValue = data.commonValue;
        } else {
          this.accountList[1].accountName = data.commonName;
          this.accountList[1].accountValue = data.commonValue;
        }
        console.log(res);
      });
    }
  },
  destroyed() {}
};
</script>

<style lang="scss">
#mainMenu {
  .m-content.account {
    margin-top: 0.2rem;
    .menu-list {
      margin: 0.1rem 0;
      font-size: 0.14rem;
      font-weight: 600;
      color: rgba(61, 61, 61, 1);
    }
  }
  .consultation {
    text-align: center;
    font-size: 0.11rem;
    font-weight: 400;
    color: rgba(177, 177, 177, 1);
    margin-top: 0.21rem;
    padding-bottom: 0.13rem;
    letter-spacing: 1px;
  }
}
</style>
